var majorityElement = function (nums) {
  let sum = 0;
  let target = 0;
  for (let i = 0; i < nums.length; i++) {
    if (sum == 0) target = nums[i];
    nums[i] == target ? sum++ : sum--;
  }
  return target;

};